#include <stdio.h>

int main()
{
    int year,mounth;
    int day[13]={0,31,28,31,30,31,30,31,30,30,31,30,31};
    
    scanf("%d %d",&year,&mounth);
    if((year%4==0 && year%100!=0)||(year%400==0))
        day[2]=29;
    printf("%d",day[mounth]);
    
    return 0;
}